<template>
  <div>
    <p>可用余额：{{ balance }}</p>
    <el-table :data="stock" border stripe >
      <el-table-column label="代码" align="center">
        <template slot-scope="scope">
          {{ scope.row.code }}
        </template>
      </el-table-column>
      <el-table-column label="名称" align="center">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column label="股票数量" align="center">
        <template slot-scope="scope">
          {{ scope.row.count.toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column label="总投入" align="center">
        <template slot-scope="scope">
          {{ scope.row.input.toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column label="成本" align="center">
        <template slot-scope="scope">
          {{ scope.row.cost.toFixed(2) }}
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      :total="total"
      :page-size="limit"
      :current-page="page"
      :page-sizes="[5,10,15,20]"
      style="padding: 30px 0;text-align: center"
      layout="->,sizes,prev,pager,next,jumper,total"
      @size-change="changePageSize"
      @current-change="changeCurrentPage"
      @prev-click="changeCurrentPage"
      @next-click="changeCurrentPage"
    />
  </div>
</template>

<script>
import wealthApi from '@/api/wealth'
export default {
  components: {

  },
  data() {
    return {
      total: 0,
      limit: 3,
      page: 0,
      balance: 0, // 可用资金
      stock: [] // 股份
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      wealthApi.list().then(res => {
        this.balance = res.data.balance
        this.stock = res.data.stock
        this.total = this.stock.length
        this.limit = this.stock.length
      })
    },
    changePageSize() {

    },
    changeCurrentPage() {

    }
  }
}

</script>
<style scoped>

</style>
